Skip to content

Added keep open boolean field to Stock Location modal form#11074

Open
spamik wants to merge 10 commits intoinventree:masterfrom
spamik:form-keep-open-feature
Open

Added keep open boolean field to Stock Location modal form#11074
spamik wants to merge 10 commits intoinventree:masterfrom
spamik:form-keep-open-feature

Conversation

@spamik
Copy link

@spamik spamik commented Jan 1, 2026

Added new boolean form field to Stock Location modal form which allows to keep form open after submitting instead closing it and redirecting browser to new stock location. This was discussed in this FR: #10412

@netlify
Copy link

netlify bot commented Jan 1, 2026

Deploy Preview for inventree-web-pui-preview failed.

Name Link
🔨 Latest commit 30cc13b
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/69afe163e80ff9000805fe43

},
location_type: {}
location_type: {},
keep_form_open: keepFormOpenField(create)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really like this method here, I would prefer a generic approach here. What do you mean @SchrodingersGat ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem out of step with how are pass other parameters. It could be a simple keep_form_open attribute

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we have this parameter for all forms on InvenTree (if it's not disabled for that form) and then don't mix the form fields with the keep open toggle we render independently at the bottom of keep open is available for that form?

@spamik
Copy link
Author

spamik commented Jan 8, 2026

Ok, I've rewrited it a little. What about now? Calling method is gone. I had to still leave there some parameter passing because I didn't figured out how to hide this field in edit forms in some other way.

@SchrodingersGat SchrodingersGat added this to the 1.3.0 milestone Feb 12, 2026
@SchrodingersGat
Copy link
Member

The button should not be within the form itself - place it down in the bottom bar:

image

@spamik
Copy link
Author

spamik commented Mar 8, 2026

Ok, I now rewritted it as a form property, enabled on create forms.

Copy link
Member

@matmair matmair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks for the contribution

@SchrodingersGat
Copy link
Member

@spamik it looks like your current implementation does not actually use the "keep open" feature in any forms yet - is this intentional?

@spamik
Copy link
Author

spamik commented Mar 9, 2026

@SchrodingersGat It shouldn't be; I added keepFormOpenOption=true to CreateApiModalForm so this option should be visible on all create forms (and at least it looks like that when I was testing it). But it's for sure possible to change this option on create form and enable it only on specific forms.

@SchrodingersGat
Copy link
Member

Please address this issue:

8:16:46 PM: $ tsc && vite build --emptyOutDir --outDir dist
8:16:56 PM: src/components/forms/ApiForm.tsx(136,9): error TS2353: Object literal may only specify known properties, and 'field_name' does not exist in type '{ field: ApiFormFieldType; definition?: ApiFormFieldType | undefined; }'.
8:16:56 PM: error Command failed with exit code 2. (https://ntl.fyi/exit-code-2)

@SchrodingersGat
Copy link
Member

@spamik I have pulled this code branch down to test, and I notice a real performance hit when toggling the "keep form open" switch.

When compared to a normal boolean input within the form (which toggles very quickly) there is a significant slow-down / lag which is introduced into the browser - especially when quickly toggling the "keep form open" input multiple times.

I have not had a chance to try to profile this yet, but this will need to be addressed before we can merge.

@spamik
Copy link
Author

spamik commented Mar 11, 2026

I'll try to look on both of the issues.

Regarding the performance hit - any idea from experienced react developers what can cause it? Because I've just used mantis switch component and on onchange event it's changing boolean property so I'm really wondering what can be wrong with this part :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants